﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <link type="text/css" rel="stylesheet" href="~/Content/bootstrap/css/bootstrap.css" />
    <link type="text/css" rel="stylesheet" href="~/Content/bootstrapvalidator/css/bootstrapValidator.css" />

    <script type="text/javascript" src="~/Content/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript" src="~/Content/bootstrapvalidator/js/bootstrapValidator.js"></script>

</head>
<body>
    <div class="container">
        <div class="row">
            <section>
                <div class="col-lg-8 col-lg-offset-2">
                    <div class="page-header">
                        <h2>Register</h2>
                    </div>
                    <div class="form-group">
                        @using (Html.BeginForm("Register", "User", FormMethod.Post, new { @class = "form-horizontal", id = "registerForm" }))
                        {
                            
                            <div class="form-group">
                                <label class="col-lg-3 control-label">Name</label>
                                <div class="col-lg-5">
                                    <input type="text" class="form-control" name="name" />
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="col-lg-3 control-label">Email address</label>
                                <div class="col-lg-5">
                                    <input type="text" class="form-control" name="email" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-lg-3 control-label">Password</label>
                                <div class="col-lg-5">
                                    <input type="password" class="form-control" name="password" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-lg-3 control-label">Retype password</label>
                                <div class="col-lg-5">
                                    <input type="password" class="form-control" name="confirmPassword" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-lg-9 col-lg-offset-3">
                                    <button type="submit" class="btn btn-primary" name="signup" value="Sign up">Sign up</button>

                                </div>
                            </div>
                        }
                    </div>
                </div>
            </section>
        </div>
    </div>



    <script type="text/javascript">
        $(document).ready(function () {
            $('#registerForm').bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    name: {
                        validators: {
                            notEmpty: {
                                message: '姓名不能为空！'
                            }
                        }
                    }, email: {
                        validators: {
                            emailAddress: {
                                required: true,
                                message: 'The input is not a valid email address'
                            },
                            remote: {
                                message: 'The username is not available',
                                type: "POST",
                                url: "CheckEmail",
                                data: {
                                    email: $("#email").val()
                                }
                            }
                        },
                        password: {
                            validators: {
                                notEmpty: {
                                    message: 'The password is required and cannot be empty'
                                },
                                identical: {
                                    field: 'confirmPassword',
                                    message: 'The password and its confirm are not the same'
                                },
                                different: {
                                    field: 'username',
                                    message: 'The password cannot be the same as username'
                                }
                            }
                        },
                        confirmPassword: {
                            validators: {
                                notEmpty: {
                                    message: 'The confirm password is required and cannot be empty'
                                },
                                identical: {
                                    field: 'password',
                                    message: 'The password and its confirm are not the same'
                                },
                                different: {
                                    field: 'username',
                                    message: 'The password cannot be the same as username'
                                }
                            }
                        }

                    }
                }
            });
            $('#signup').click(function () {
                $('#registerForm').bootstrapValidator('validate');
            });

            $('#resetBtn').click(function () {
                $('#defaultForm').data('bootstrapValidator').resetForm(true);
            });
        });

    </script>




</body>
</html>
